<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>查看瓦片坐标</title>
    <link rel="stylesheet" href="../v6.4.3/css/ol.css">
  </head>

  <body>
    <!-- 核心地图容器 -->
    <div id="map" style="height: 500px;"></div>

    <script src="../v6.4.3/build/ol.js"></script>
    <script>
      const osmSource = new ol.source.OSM()
      const map = new ol.Map({
        target: 'map',
        layers: [
          //Open Street Map地图
          new ol.layer.Tile({
            source: osmSource
          }),
          //显示OSM地图瓦片网格的图层
          new ol.layer.Tile({
            source: new ol.source.TileDebug({
              projection: 'EPSG:3857',
              tileGrid: osmSource.getTileGrid() //获取OSM地图的瓦片坐标系
            })
          })
        ],
        view: new ol.View({
          projection: 'EPSG:3857',
          center: ol.proj.transform([104, 30], 'EPSG:4326', 'EPSG:3857'),
          zoom: 10
        })
      })
    </script>
  </body>
</html>